package com.ht.controller;

import com.ht.data.Result;
import com.ht.domain.bo.MyDoctorBO;
import com.ht.domain.bo.TbDoctorBO;
import com.ht.domain.bo.TbHospitalBO;
import com.ht.domain.po.TbHospital;
import com.ht.domain.vo.MyDoctorVO;
import com.ht.domain.vo.TbDoctorVO;
import com.ht.domain.vo.TbHospitalVO;
import com.ht.dto.TbDiagnoseOrderDTO;
import com.ht.dto.TbDoctorDTO;
import com.ht.feign.AppointmentRegisteredFeign;
import com.ht.feign.ExpertOutpatientFeign;
import com.ht.feign.PublicOutpatientFeign;
import com.ht.mapper.TbDoctorMapper;
import com.ht.service.MyDoctorService;
import com.ht.service.TbDoctorService;
import com.ht.service.TbHospitalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController  //等于@Restquest + @Controller
@RequestMapping("/remoteVdeo")
@Api("快速问医生管理系统")
@RefreshScope  //实时刷新
public class RemoteVdeoController {

    @Autowired
    private TbHospitalService tbHospitalService;

    @Autowired
    private TbDoctorService tbDoctorService;

    @Autowired
    private MyDoctorService myDoctorService;

    @Autowired
    private AppointmentRegisteredFeign appointmentRegisteredFeign;

    @Autowired
    private ExpertOutpatientFeign expertOutpatientFeign;



    /**
     *
     * @param provinceId  省id   全国/0
     * @param departmentId  科室id 全部/0
     * @return
     */
    @PostMapping("/queryDoctor")
    @ApiOperation("根据省级id查询医生")
    @ApiImplicitParam()
    public Result queryDoctor(Long provinceId,Long departmentId){
        List<TbDoctorVO> listt = new ArrayList<>();
        if (provinceId == 0){
            if (departmentId == 0){
                List<TbDoctorBO> list = tbDoctorService.queryDoctor();
                list.forEach(obj->{
                    TbDoctorVO vo = new TbDoctorVO();
                    BeanUtils.copyProperties(obj,vo);
                    listt.add(vo);
                });
                return Result.OK().setData(listt);
            }else{
                Result result = appointmentRegisteredFeign.queryDoctorBydepartmentIdAndStatus(departmentId,0,0L,0L);
                return  result;
            }
        }else{
            List<TbDoctorBO> list = tbDoctorService.queryDoctorByDepartmentIdAndProvinceId(provinceId,departmentId);
        }
        return null;
    }


    @PostMapping("/queryDoctorCost")
    @ApiOperation("选定医生缴费")
    @ApiImplicitParam()
    public Result queryDoctor(TbDiagnoseOrderDTO dto){
        Result result = expertOutpatientFeign.outpatientRegistered(dto);
        return result;
    }

}
